package com.weibo.demos.web.Mapper;


import com.weibo.demos.web.entity.WeiboDTO;
import com.weibo.demos.web.entity.WeiboDetailVO;
import com.weibo.demos.web.entity.WeiboVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WeiboMapper {


    @Insert("insert into weibo(content,user_id,created) values(#{content},#{userId},now())")
    void insert(WeiboDTO weibo);

    @Select("select w.id,u.nickname,w.content from weibo w , user u where w.user_id=u.id order by w.created desc")
    List<WeiboVO> selectIndex();

    @Select("select w.id, u.nickname,w.content,w.created from user u,weibo w where w.id = #{id}  and u.id = w.user_id")
    WeiboDetailVO selectById(Integer id);
}
